from flask import Blueprint, jsonify
from ..models import VaccinationSite
from flask_jwt_extended import jwt_required

vaccination_site_bp = Blueprint('vaccination_site', __name__)

@vaccination_site_bp.route('/list', methods=['GET'])
def get_sites():
    """获取接种点列表"""
    sites = VaccinationSite.query.all()
    return jsonify({
        'code': 200,
        'msg': '获取成功',
        'data': [{
            'id': site.id,
            'name': site.name,
            'address': site.address,
            'vaccineCount': site.vaccineCount,
            'status': site.status
        } for site in sites]
    }), 200

@vaccination_site_bp.route('/<int:id>', methods=['GET'])
def get_site_detail(id):
    """获取单个接种点详情"""
    site = VaccinationSite.query.get_or_404(id)
    return jsonify({
        'code': 200,
        'msg': '获取成功',
        'data': {
            'id': site.id,
            'name': site.name,
            'address': site.address,
            'vaccineCount': site.vaccineCount,
            'status': site.status
        }
    }), 200 